package com.aaa.controller;


import com.aaa.entity.Comment;
import com.aaa.service.impl.CommentServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-07
 */
@Api(tags = "评论接口")
@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    CommentServiceImpl commentService;
    //查看评论
    @ApiOperation("查看作品和评论")
    @RequestMapping(value = "selecomment",method = RequestMethod.POST)
    public List<Map<String,Object>> selecomment(@ApiParam("视频id") Integer vid,@ApiParam("用户id")Integer uid){
        return commentService.selecomment(vid,uid);
    }



    @ApiOperation("添加一级评论")
    @RequestMapping(value = "addtop",method = RequestMethod.POST)
    public boolean addtop(@ApiParam("评论人id") Integer uid,@ApiParam("评论人昵称") String uname,
                          @ApiParam("作品的id") Integer vid,@ApiParam("评论的内容") String content){
        return commentService.addtop(uid,uname,vid,content);
    }


    @ApiOperation("回复一级评论")
    @RequestMapping(value = "addtwo",method = RequestMethod.POST)
    public boolean addtwo(@ApiParam("评论人id") Integer uid,@ApiParam("评论人昵称") String uname,@ApiParam("作品的id")
            Integer vid,@ApiParam("一级评论的id") Integer parentid,@ApiParam("一级评论人的id")Integer parentuid,@ApiParam("评论的内容") String content){
        return commentService.addtwe(uid,uname,vid,parentid,parentuid,content);
    }

    @ApiOperation("回复二级评论")
    @RequestMapping(value = "addtworeply",method = RequestMethod.POST)
    public boolean addtworeply(@ApiParam("一级评论人的id") Integer parentuid,Comment comment){
        return commentService.addtworeply(comment,parentuid);
    }
}
